#include "ParsingErrorHandler.h"

namespace XMLSAX
{
	namespace Core
	{
		ParsingErrorHandler::ParsingErrorHandler()
		{

		}

		ParsingErrorHandler::~ParsingErrorHandler()
		{

		}

		long __stdcall ParsingErrorHandler::QueryInterface( const struct _GUID &, void ** )
		{
			return 0;
		}

		unsigned long __stdcall ParsingErrorHandler::AddRef( void )
		{
			return 0;
		}

		unsigned long __stdcall ParsingErrorHandler::Release()
		{
			return 0;
		}

		HRESULT STDMETHODCALLTYPE ParsingErrorHandler::error( ISAXLocator *pLocator, const wchar_t *pErrorMessage, HRESULT hErrorCode )
		{
			HRESULT hrReturn = S_OK;

#ifdef _DEBUG
			OutputDebugString(pErrorMessage);
#endif

			if(IDNO == MessageBox(NULL, pErrorMessage, L"An Error has occured. Continue parsing the document?", MB_YESNO | MB_ICONQUESTION))
				hrReturn = ((HRESULT)-1);

			return hrReturn;
		}

		HRESULT STDMETHODCALLTYPE ParsingErrorHandler::fatalError( ISAXLocator *pLocator, const wchar_t *pErrorMessage, HRESULT hErrorCode )
		{
			MessageBox(NULL, pErrorMessage, L"Fatal Error in parsing the document!", MB_OK | MB_ICONSTOP);

#ifdef _DEBUG
			return S_OK;
#else
			return ((HRESULT)-1);
#endif
		}

		HRESULT STDMETHODCALLTYPE ParsingErrorHandler::ignorableWarning( ISAXLocator *pLocator, const wchar_t *pErrorMessage, HRESULT hErrorCode )
		{

#ifdef _DEBUG
			OutputDebugString(pErrorMessage);
#endif

			return S_OK;
		}
	}
}